
export default [

  // 根
  {
    path: '/',
    redirect: '/home'
  },
  // 商品详情
  {
    path: '/detail/:skuId',
    component: () => import('@/views/Detail'),
    meta: { show: true }
  },
  // 首页
  {
    path: '/home',
    component: () => import('@/views/Home'),
    meta: { show: true }
  },
  // 登陆
  {
    path: '/login',
    component: () => import('@/views/Login'),
    meta: { show: false }
  },
  // 注册
  {
    path: '/register',
    component: () => import('@/views/Register'),
    meta: { show: false }
  },
  // 搜索
  {
    path: '/search/:keyword?',
    component: () => import('@/views/Search'),
    meta: { show: true },
    name: 'search'
  },
  // 加入购物车成功
  {
    path: '/addcartsuccess',
    component: () => import('@/views/AddCartSuccess'),
    meta: { show: true },
    name: 'addcartsuccess'
  },
  // 购物车
  {
    path: '/shopcart',
    component: () => import('@/views/ShopCart'),
    meta: { show: true },
    name: 'shopcart'
  },
  // 订单结算
  {
    path: '/trade',
    component: () => import('@/views/Trade'),
    meta: { show: true },
    name: 'trade',
    beforeEnter(to, from, next) {
      /* must call `next` */
      if (from.path === '/shopcart') {
        next()
      } else {
        next(false)
      }
    }
  },
  // 支付
  {
    path: '/pay',
    component: () => import('@/views/Pay'),
    meta: { show: true },
    name: 'pay',
    beforeEnter(to, from, next) {
      /* must call `next` */
      if (from.path === '/trade') {
        next()
      } else {
        next(false)
      }
    }
  },
  // 支付成功
  {
    path: '/paysuccess',
    component: () => import('@/views/PaySuccess'),
    meta: { show: true },
    name: 'paysuccess',
    beforeEnter(to, from, next) {
      /* must call `next` */
      if (from.path === '/pay') {
        next()
      } else {
        next(false)
      }
    }
  },
  // 个人中心
  {
    path: '/center',
    component: () => import('@/views/Center'),
    meta: { show: true },
    name: 'center',
    children: [
      {
        // 我的订单
        path: 'myorder',
        component: () => import('@/views/Center/MyOrder')
      },
      {
        // 团购订单
        path: 'grouporder',
        component: () => import('@/views/Center/GroupOrder')
      },
      {
        // 默认展示我的订单
        path: '',
        redirect: '/center/myorder'
      }
    ]
  }
]
